<!DOCTYPE html>
<html ng-app="myApp">

<head>
    <meta charset="utf-8">
    <script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>

<body>
    <div ng-controller="personCtrl">
        <button ng-click="myToggle()">隐藏/显示</button>

        <p ng-hide="myVar">
            <input type="text" name="" ng-model="firstName">
            <br>
            <input type="text" name="" ng-model="lastName">
            <br>

            姓名：{{ firstName + " " + lastName}}
        </p>
    </div>
    <script type="text/javascript">
        var app = angular.module('myApp', []);
        app.controller('personCtrl', ['$scope', function($scope) {
            $scope.firstName = "John";
            $scope.lastName = "Deo";
            $scope.myVar = false;
            $scope.myToggle = function () {
                $scope.myVar = !$scope.myVar;
            };
        }]);
    </script>
</body>

</html>


